package org.lanqiao.sjx.dao.impl;

import java.sql.SQLException;
import java.util.List;

import javax.sound.midi.MidiDevice.Info;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.lanqiao.bean.Education;
import org.lanqiao.sjx.dao.EducationDao;
import org.lanqiao.tools.BaseDao;

public class EducationImpl extends BaseDao implements EducationDao{

	@Override
//	这里的userID时根据登录的用户传来的
	public Integer insertEdu(Education info) {
		// TODO Auto-generated method stub
		String sql="insert into education (userID,StartYear,endYear,schoolName,"
				+ "eduBackground,majorName,date) values(?,?,?,?,?,?,Now())";
		try {
			return query.update(sql,info.getUserID(),info.getStartYear(),info.getEndYear(),
					info.getSchoolName(),info.getEduBackground(),info.getMajorName());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer updateEdu(Education info) {
		// TODO Auto-generated method stub
		String sql="update  education set startYear=?,endYear=?,schoolName=?,eduBackground=?,majorName=?,date=Now() "
				+ "where id=?";
		try {
			return query.update(sql,info.getStartYear(),info.getEndYear(),
					info.getSchoolName(),info.getEduBackground(),info.getMajorName(),info.getId());
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public List<Education> selectEducation(Integer userID) {
		// TODO Auto-generated method stub
		String sql="select * from education where userID=?";
		try {
			return query.query(sql, new BeanListHandler<Education>(Education.class),userID);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Integer deleteEdu(Integer id) {
		// TODO Auto-generated method stub
		String sql="delete from education where id=? and userID=?";
		return null;
	}

	@Override
	public Integer getCountEdu() {
		// TODO Auto-generated method stub
		return null;
	}

}
